<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserProfilesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_profiles', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();
            $table->unsignedBigInteger('user_id')->index('user_id')->comment('用户ID');
            $table->text('bio')->comment('个人简介');
            $table->string('website', 500)->comment('个人网站')->nullable();
            $table->string('location', 100)->comment('所在地')->nullable();
            $table->string('company', 100)->comment('公司')->nullable();
            $table->string('github', 100)->comment('Github用户名')->nullable();
            $table->string('twitter', 100)->comment('twitter用户名')->nullable();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

            $table->comment('用户资料表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_profiles');
    }
}
